package com.yanqu.road.server.cmd.curio;

import com.yanqu.road.entity.curio.CurioLotteryNoticeData;
import com.yanqu.road.entity.servercenter.ServerGroup;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.cangbao.CurioProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.curio.CrossCurioMgr;
import com.yanqu.road.server.manger.ServerGroupMgr;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.utils.YanQuMessageUtils;

@Cmd(code = CrossProtocol.C_CURIO_LOTTERY_GET_NOTICE, desc = "公告")
public class CrossCurioLotteryGetNoticeCmd extends CrossCommand {


    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {

        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

        int groupId = (int)serverId;
        ServerGroup serverGroup = ServerGroupMgr.getServerGroupByServerId(serverId);
        if(serverGroup != null && serverGroup.isCrossRank()) {
            groupId = serverGroup.getGroupId();
        }

        CurioProto.GetCurioLotteryNoticeRespMsg.Builder builder = CurioProto.GetCurioLotteryNoticeRespMsg.newBuilder();
        builder.setRet(ret);
        for (CurioLotteryNoticeData notice : CrossCurioMgr.getNoticeData(groupId)) {
            builder.addNoticeList(CrossCurioMgr.parseNoticeMsg(notice));
        }
        MessageHelper.sendPacket(serverId, packet.getPlayerId(), YanQuMessageUtils.buildMessage(ClientProtocol.U_CURIO_DRAW_NOTICE, builder));
    }

    @Override
    public void sendData() {

    }
}
